#include "include/start-stop.h"

void write_in_file(int flag)
{
  FILE *fp;

   if((fp=fopen("start-stop", "w")) == NULL) {
    printf("Cannot open file.\n");
    exit(1);
  }

  fprintf(fp, "%d", flag); /* write to file */
  fclose(fp); 

 }
 
 
int my_system (const char *command)
{
  int status;
  pid_t pid;

  pid = fork ();
  if (pid == 0)
    {
      /* This is the child process.  Execute the shell command. */
      execl (SHELL, SHELL, "-c", command, NULL);
      _exit (EXIT_FAILURE);
    }
  else if (pid < 0)
    /* The fork failed.  Report failure.  */
    status = -1;
  else
    /* This is the parent process.  Wait for the child to complete.  */
    if (waitpid (pid, &status, 0) != pid)
      status = -1;
  return status;
}
